package com.go.dp.strategy.one;

public class Sortor {
	public static Object[] sort(Comparable[] a) {
		for (int i = 0; i < a.length; ++i) {
			for (int j = a.length - 1; j > i; --j) {
				if (-1 == a[j].compareTo(a[j - 1])) {
					swap(a, j, j - 1);
				}
			}
		}
		return a;
	}

	private static void swap(Object[] a, int x, int y) {
		Object temp;
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

	public static void print(Object[] array) {
		for (Object e : array) {
			System.out.print(e + " ");
		}
		System.out.println("");
	}
}
